// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const user = db.collection('user')
const clubco = db.collection('club')
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  console.log('clubchecking 为：'+JSON.stringify(event.clubchecking))
  console.log('clubid 为：'+JSON.stringify(event.clubid))
  try {
     await user.where({
      _openid :wxContext.OPENID,
    }).update({
      data:{
        clubchecking:event.clubchecking,

      }      
    })

    await clubco.where({
      _id:event.clubid
    }).update({
      data:{
        checkmember:event.checkmember
      }

    })
    


  } catch (error) {
    console.log(error)
    
  }

  return {
    event,
    openid: wxContext.OPENID,
    appid: wxContext.APPID,
    unionid: wxContext.UNIONID,
  }
}